import os
from jili.tool.convert import str2datetime
from jili.core import load
def iter_tick(obj, url, start=None, end=None):
    l = os.listdir(os.path.join(url, obj))
    l.sort()
    for i in l:
        if start:
            if str2datetime(start) > str2datetime(i.split(".")[0].split("_")[-1]):
                continue
        if end:
            if str2datetime(end) < str2datetime(i.split(".")[0].split("_")[-1]):
                continue
        a = load(os.path.join(url, obj, i))
        for t in a:
            yield t
def iter_dayticks(obj, url, start=None, end=None):
    l = os.listdir(os.path.join(url, obj))
    l.sort()
    for i in l:
        if start:
            if str2datetime(start) > str2datetime(i.split(".")[0].split("_")[-1]):
                continue
        if end:
            if str2datetime(end) < str2datetime(i.split(".")[0].split("_")[-1]):
                continue
        a = load(os.path.join(url, obj, i))
        yield a